<template>
	<view class="page">
		<!-- <u-navbar :isBack="false" :title="miniProgramName" title-color="#101010" 
		:background="{background: '#fff'}" :borderBottom="false"></u-navbar> -->
		
		<view class="top-box" :style="{backgroundImage:'url(' + topImage + ')'}">
			<view style="padding: 200rpx 32rpx 0 32rpx;font-size: 28rpx;display: flex;align-items: center;">
				<image :src="userinfo.avatar" mode="aspectFill" 
				style="width: 140rpx;height: 140rpx;border-radius: 50%;"></image>
				<view style="flex: 1;margin-left: 24rpx;">
					<view style="font-size: 36rpx;font-weight: bold;color: #00091A;display: flex;">
						<view>{{userinfo.name}}</view>
						<!-- 0金色 1灰色 2绿色 3蓝色 4红色 -->
						<view style="margin-left: 20rpx;" v-if="userinfo.identity == 2">
							<text style="font-size: 20rpx;color: #19be6b;background: #dbf1e1;
							padding: 4rpx 12rpx;border-radius: 8rpx;">注册用户</text>
						</view>
						<view style="margin-left: 20rpx;" v-if="userinfo.identity == 3">
							<text style="font-size: 20rpx;color: #2979ff;background: #ecf5ff;
							padding: 4rpx 12rpx;border-radius: 8rpx;">推广达人</text>
						</view>
						<view style="margin-left: 20rpx;" v-if="userinfo.identity == 4">
							<text style="font-size: 20rpx;color: #fa3534;background: #fef0f0;
							padding: 4rpx 12rpx;border-radius: 8rpx;">推广团长</text>
						</view>
						<view style="margin-left: 20rpx;" v-if="userinfo.identity == 1">
							<text style="font-size: 20rpx;color: #909399;background: #f4f4f5;
							padding: 4rpx 12rpx;border-radius: 8rpx;">普通会员</text>
						</view>
						<view style="margin-left: 20rpx;" v-if="userinfo.identity == 0">
							<text style="font-size: 20rpx;color: #ffea00;background: #fffff6;
							padding: 4rpx 12rpx;border-radius: 8rpx;">铁班底</text>
						</view>
					</view>
					<view style="margin-top: 10rpx;display: flex;">
						<view style="color: #666666;font-size: 28rpx;">{{userinfo.username}}</view>
						<view style="margin-left: 20rpx;">
							<text style="font-size: 20rpx;color: #909399;background: #f4f4f5;
							padding: 4rpx 12rpx;border-radius: 8rpx;">到期时间：{{userinfo.expirationtime}}</text>
						</view>
					</view>
				</view>
				<!-- <view style="display: flex;align-items: center;" @click="jumpTo('/pages/my/setup')">
					<image src="@/static/my/set.png" mode="widthFix" style="width: 48rpx;"></image>
				</view> -->
			</view>
			
			<!-- <view style="padding: 200rpx 32rpx 0 32rpx;font-size: 28rpx;display: flex;align-items: center;"
			v-else>
				<image src="@/static/my/notop.png" mode="aspectFill" style="width: 140rpx;height: 140rpx;"></image>
				<view style="flex: 1;margin-left: 24rpx;" @click="jumpTo('/pages/login/login')">
					<view style="font-size: 36rpx;font-weight: bold;color: #00091A;">尚未登录，去登录</view>
					<view style="color: #666666;margin-top: 10rpx;font-size: 28rpx;">登录体验更多功能</view>
				</view>
			</view> -->
		</view>
		
		<view style="padding: 40rpx 32rpx 0 32rpx;">
			<view style="display: flex;align-items: center;">
				<!-- <view style="text-align: center;width: 50%;">
					<view style="color: #333333;font-size: 36rpx;font-weight: bold;">{{ userinfo.task_sum || 0 }}</view>
					<view style="color: #999999;font-size: 24rpx;margin-top: 8rpx;">任务完成数</view>
				</view> -->
				<view style="text-align: center;flex: 1;">
					<view style="color: #333333;font-size: 36rpx;font-weight: bold;">{{ userinfo.promoters_sum || 0 }}</view>
					<view style="color: #999999;font-size: 24rpx;margin-top: 8rpx;">推广人数</view>
				</view>
				<view style="text-align: center;width: 50%">
					<view style="color: #333333;font-size: 36rpx;font-weight: bold;">{{ userinfo.extension_sum || 0 }}</view>
					<view style="color: #999999;font-size: 24rpx;margin-top: 8rpx;">推广完成数</view>
				</view>
			</view>
		</view>
		
		<view style="padding: 40rpx 32rpx 0 32rpx;">
			<view style="display: flex;justify-content: space-between;">
				<view style="width: 330rpx;height: 74px;background: #fff;border-radius: 24rpx;
				display: flex;align-items: center;padding-left: 24rpx;padding-right: 24rpx;"
				@click="jumpTo('/pages/my/invitation')" v-if="userinfo.task_sum > 9">
					<view style="flex: 1;">
						<view style="color: #333333;font-size: 36rpx;font-weight: bold;">邀请好友</view>
						<view style="color: #999999;font-size: 24rpx;margin-top: 8rpx;">邀好友共同参与</view>
					</view>
					<image src="@/static/my/yqtg.png" mode="widthFix" style="width: 84rpx;"></image>
				</view>
				<view style="width: 330rpx;height: 74px;background: #fff;border-radius: 24rpx;
				display: flex;align-items: center;padding-left: 24rpx;padding-right: 24rpx;"
				@click="jumpTo('/pages/my/myPromotion')">
					<view style="flex: 1;">
						<view style="color: #333333;font-size: 36rpx;font-weight: bold;">我的团队</view>
						<view style="color: #999999;font-size: 24rpx;margin-top: 8rpx;">查看团队成员</view>
					</view>
					<image src="@/static/my/wdtd.png" mode="widthFix" style="width: 84rpx;"></image>
				</view>
			</view>
			
			<view style="margin-top: 120rpx;padding: 24rpx;color: #50A5F4;border: 2rpx solid #50A5F4;
			border-radius: 16rpx;text-align: center;" @click="tuiChu">
				退出登录
			</view>
			
		</view>
		
		
		<!-- <view style="position: fixed;bottom: 120rpx;width: 100%;">
			<image src="../../static/bottomimg.png" mode="widthFix" style="width: 100%;"></image>
		</view> -->
		
		<u-toast ref="uToast" />
		
		<!-- <CuTabbar current="my"></CuTabbar> -->
		<u-tabbar v-model="current" :list="tabbar" active-color="#50A5F4"></u-tabbar>
	</view>
</template>

<script>
	import {getTabbarConfig} from '@/common/tabbar';
	import appurl_config from 'utils/config.js'
	import {request} from 'utils/request.js'
	import Vue from 'vue'
	var moment = require('moment');
	export default {
		data() {
			return {
				current: 1,
				tabbar: getTabbarConfig(true),
				
				topImage: 'https://jdrm.smomotbo.com/my/topbg.png',
				
				meetList: [],
				date:'',
				showCancelConfirm:false,
				showOverConfirm:false,
				id:'',
				
				beingNum:0,
				waitNum:0,
				orList:[],
				state:1,
				
				list: [
					{
						name: '全部'
					}, {
						name: '未读'
					}, {
						name: '私聊',
						// count: 5
					}, {
						name: '群聊'
					}, {
						name: '通知'
					}
				],
				current: 0,
				
				
				userinfo: {},
				isLogin: false,
			}
		},
		onLoad() {
			// this.login();
			// 告诉页面需要刷新登录状态
			uni.$on('htmlRefresh', (e) => {
				console.log('子页面---->>>>>>', e);
				this.userInfoData();
			});
			uni.hideShareMenu();
		},
		onShow(){
			let userToken = uni.getStorageSync('userToken');
			if(userToken){
				this.userInfoData();
			}
		},
		methods: {
			userInfoData(){
				request.getWithToken({
					url: '/user/userInfo'
				}).then(res=>{
					console.log('返回用户信息：', res);
					if(res.code == 1){
						this.userinfo = res.data.user;
						if(res.data.user){
							this.isLogin = true;
						}else{
							this.isLogin = false;
						}
					}
				})
			},
			jumpTo(path){
				// if(this.isLogin){
					uni.navigateTo({
						url: path
					})
				// 	return;
				// }
				// uni.navigateTo({
				// 	url: '/pages/login/login'
				// })
				
			},
			toDetail(item){
				Vue.prototype.MeetInfo = item
				uni.navigateTo({
					url:'detail'
				})
			},
			tuiChu(){
				uni.removeStorageSync('userToken');
				setTimeout(() => {
					uni.navigateTo({
						url: '/pages/login/login'
					})
				}, 300);
			}
		}
	}
</script>

<style>
	page{
		background-color: #F5F8FF !important;
	}
</style>
<style lang="scss" scoped>
	.top-box{
		background-size: 100% 160%;
	}
</style>
